const ProjectRequest = require("../project/project_request.js");
const Url = require("../utils/url.js");

function page(startPage, state, callback) {
  const URL = Url.newInstance("/order/manage/page");
  URL.setPara('startPage', startPage)
  URL.setPara('state', state)
  ProjectRequest.getRequest(URL.get(), callback);
}

function findByIdWithProducts(orderId, callback) {
  const URL = Url.newInstance("/order/manage/" + orderId);
  URL.setPara('showProduction', true)
  ProjectRequest.getRequest(URL.get(), callback);
}

function assignPage(callback) {
  const url = "/order/manage/assign/page";
  ProjectRequest.getRequest(url, callback);
}

function assign(orderId, branchCompanyStaffId, callback) {
  const url = "/order/manage/" + orderId + "assign/" + branchCompanyStaffId;
  ProjectRequest.getRequest(url, callback);
}

function send(orderId, callback) {
  const url = "/order/manage/" + orderId + "send";
  ProjectRequest.getRequest(url, callback);
}

function terminal(orderId, callback) {
  const url = "/order/manage/" + orderId + "terminal";
  ProjectRequest.getRequest(url, callback);
}

function finish(orderId, callback) {
  const url = "/order/manage/" + orderId + "finish";
  ProjectRequest.getRequest(url, callback);
}

function submitVerify(orderId, callback) {
  const url = "/order/manage/" + orderId + "submitVerify";
  ProjectRequest.getRequest(url, callback);
}

function verifyPass(orderId, callback) {
  const url = "/order/manage/" + orderId + "verifyPass";
  ProjectRequest.getRequest(url, callback);
}

/**
 * exports
 */
module.exports = {
  page,
  findByIdWithProducts,
  assignPage, assign, send,
  terminal, finish,
  submitVerify, verifyPass
};